/*
 * @lc app=leetcode.cn id=1763 lang=javascript
 *
 * [1763] 最长的美好子字符串
 */

// @lc code=start
var isNiceString = function (str = "") {
  return str.split('').every(ch => {
    if (ch.charCodeAt() >= 97) {
      return str.includes(ch.toUpperCase());
    } else {
      return str.includes(ch.toLowerCase());
    }
  })
}
/**
 * @param {string} s
 * @return {string}
 */
var longestNiceSubstring = function (s) {
  let res = "";
  let max = 0;
  for (let i = 0; i < s.length; i++) {
    for (let j = i + 1; j < s.length; j++) {
      let str = s.slice(i, j + 1);
      if (isNiceString(str) && str.length > max) {
        res = str;
        max = str.length;
      }
    }
  }
  return res;
};
// @lc code=end

